#定义一个银行账号信息的列表
usershow=[
	{'user_card':'card01','password':'123456','balance':5000},
	{'user_card':'card02','password':'234567','balance':4500},
	{'user_card':'card03','password':'345678','balance':9000}]
#定义一个账号信息输出函数
def function():
	'''
	账号信息存取操作函数
	'''
	for i in range(len(usershow)):
		if usershow[i]['user_card']==keyuser and usershow[i]['password']==keypass:#判断账号密码是否正确
			'''
			账号存取查询操作界面输出
			'''
			print("-"*43)
			print("|{0:<1} {1:<10} {2:<10} {3:<10}|".format("","1.存钱","2.取钱","3.查询余额"))
			print("-"*43)
			a=input("请输入需要执行的功能：")#功能选择
			if a=="1":
				deposit(keyuser)
				break
			elif a=="2":
				Wdmoney(keyuser)
				break
			elif a=="3":
				Shmonony(keyuser)
				break
			else:
				print("无效命令")
				break
	else:
		print("卡号或密码输入错误")#账号密码错误输出
	#存取界面完成后退出选择界面
	print("-"*28)
	print("|{0:<1} {1:<8} {2:<8}|".format("","1.返回上级","2.退出系统"))
	print("-"*28)
	b=input("请选择功能：")
	if b=='1':
		function()
		return
	elif b=='2':
		return
	else:
		print("无效命令")



def deposit(user):
	#存款函数
	dep=float(input("请输入存款的金额："))
	for i in range(len(usershow)):
		if usershow[i]['user_card']==user:
			usershow[i]['balance']=usershow[i]['balance']+dep
			print('存款成功,当前账户余额:')
			Shmonony(keyuser)
	return
def Wdmoney(user):
	#取款函数
	wdf=float(input("请输入取款金额："))
	for i in range(len(usershow)):
		if usershow[i]['user_card']==user and usershow[i]['balance']>=wdf:
			usershow[i]['balance']=usershow[i]['balance']-wdf
			print("取款成功,当前账户余额：")
			Shmonony(keyuser)
			break
	else:
		print("余额不足！！！")
	return
def Shmonony(user):
	#显示余额函数
	for i in range(len(usershow)):
		if  usershow[i]['user_card']==user:
			print("-"*43)
			print("|{0:1} {1:<10}|{2:<10}".format("","Card","Balance"))
			print("|{0:1} {1:<10}|{2:<10}".format("",usershow[i]['user_card'],usershow[i]['balance']))
			print("-"*43)
	return
while True:
	#ATM机初始登陆面板
	print("="*12,"AIM机自动存取系统","="*12)
	print("-"*43)
	print(" "*12,"登陆你的账户"," "*12)
	print("-"*43)
	keyuser=input("请输入卡号：")
	keypass=input("请输入密码：")
	function()
	break